//
//  FansCell.m
//  WanCaiC8
//
//  Created by tangang on 2018/1/19.
//  Copyright © 2018年 tangang. All rights reserved.
//

#import "FansCell.h"

@implementation FansCell{
    UIImageView *imageV;
    QXLable     *labName;
    QXLable     *labSignature;
    QXLable     *labFocus;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        WS(weakSelf);
        self.selectionStyle=UITableViewCellSeparatorStyleNone;
        imageV=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"avatar"]];
        imageV.layer.masksToBounds=YES;
        imageV.layer.cornerRadius=25;
        [self.contentView addSubview:imageV];
        [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).with.offset(13);
            make.centerY.equalTo(weakSelf.contentView);
            make.size.mas_equalTo(CGSizeMake(50, 50));
        }];
        
        labName=[[QXLable alloc]initTitle];
        labName.text=@"一只安静的哈士奇";
        [self.contentView addSubview:labName];
        [labName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(imageV.mas_right).with.offset(13);
            make.top.equalTo(imageV).with.offset(5);
        }];
        
        labSignature=[[QXLable alloc]initWithFount:12];
        labSignature.text=@"生活只有彩票";
        labSignature.numberOfLines=1;
        [self.contentView addSubview:labSignature];
        [labSignature mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(imageV.mas_right).with.offset(13);
            make.right.equalTo(weakSelf.contentView).with.offset(-80);
            make.bottom.equalTo(imageV).with.offset(-5);
        }];
        
        labFocus=[[QXLable alloc]initWithFount:14];
        labFocus.layer.masksToBounds=YES;
        labFocus.layer.borderWidth=1.0;
        labFocus.layer.cornerRadius=2.0;
        labFocus.userInteractionEnabled=YES;
        UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onclickTap)];
        [labFocus addGestureRecognizer:tap];
        labFocus.textAlignment=NSTextAlignmentCenter;
        [self.contentView addSubview:labFocus];
        [labFocus mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(weakSelf.contentView).with.offset(-13);
            make.centerY.equalTo(weakSelf.contentView);
            make.size.mas_equalTo(CGSizeMake(54, 27));
        }];
        
        UIView *line=[[UIView alloc]init];
        line.backgroundColor=DEFAULTBGCOLOR;
        [self.contentView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(weakSelf.contentView);
            make.height.mas_equalTo(@.7);
        }];
    }
    return self;
}


- (void)onclickTap{
    if (self.focusBlock) {
        self.focusBlock(self.fouseModel);
    }
}

- (void)setFouseModel:(FouseModel *)fouseModel{
    _fouseModel=fouseModel;
    [imageV sd_setImageWithURL:[NSURL URLWithString:fouseModel.Avater]];
    labName.text=fouseModel.NickName;
    labSignature.text=fouseModel.Autograph;
    if (fouseModel.Status==1) {
        labFocus.textColor=DEFAULTTEXTGRAYCOLOR;
        labFocus.layer.borderColor=DEFAULTTEXTGRAYCOLOR.CGColor;
        labFocus.text=@"已关注";
    }else{
        labFocus.textColor=NAVCOLOR;
        labFocus.layer.borderColor=NAVCOLOR.CGColor;
        labFocus.text=@"关注";
    }
}

@end
